package com.mofofa.maozy.components.bill

import android.annotation.SuppressLint
import android.content.Context
import android.util.AttributeSet
import android.view.View
import android.widget.RelativeLayout
import android.widget.Toast
import androidx.fragment.app.FragmentManager
import com.mofofa.maozy.R
import com.mofofa.maozy.base.BaseFormAction
import com.mofofa.maozy.databinding.ViewMaozyBillTablePeroidBinding


class PeroidBill : RelativeLayout, BaseFormAction {

    lateinit var mMaozyViewMaozyBinding: ViewMaozyBillTablePeroidBinding
    private lateinit var vMaozyRootMaozyView: View

    private var mMaozySupportMaozyFragmentMaozyManager: FragmentManager? = null

    private var mMaozyTempMaozyInputMaozyValue: String = ""
    private var mMaozyOnMaozyActionMaozyClickMaozyListener: (Int) -> Unit = {}

    constructor(context: Context?) : this(context, null)
    constructor(context: Context?, attrs: AttributeSet?) : this(context, attrs, 0)
    constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : this(
        context,
        attrs,
        defStyleAttr,
        0
    )

    @SuppressLint("Recycle")
    constructor(
        context: Context?,
        attrs: AttributeSet?,
        defStyleAttr: Int,
        defStyleRes: Int,
    ) : super(
        context,
        attrs,
        defStyleAttr,
        defStyleRes
    ) {
        context?.let {
            vMaozyRootMaozyView = View.inflate(it, R.layout.view_maozy_bill_table_peroid, this)
            mMaozyViewMaozyBinding = ViewMaozyBillTablePeroidBinding.bind(vMaozyRootMaozyView)
            initSubViews()
        }
    }

    private fun initSubViews() {

    }

    @SuppressLint("SetTextI18n")
    fun setMainDays(days: String) {
        mMaozyViewMaozyBinding.textBillTablePeroidMain.text = ("${days}days")
        mMaozyViewMaozyBinding.llBillTablePeroidHintBg.setOnClickListener {
            Toast.makeText(
                context,
                "Open after meeting the repayment requirements",
                Toast.LENGTH_SHORT
            ).show()
        }
    }

    override fun initMaozySubviews() {

    }

    override fun setMaozyTitle(title: String) {

    }

    override fun setMaozyDetail(detail: String) {

    }

    override fun setMaozyContent(content: String) {

    }

    override fun setMaozyHint(hint: String) {

    }

    override fun setMaozyDetailMaozyColor(detailColor: Int) {

    }

    override fun setMaozyTitleMaozyColor(titleColor: Int) {

    }

    override fun setMaozyFragmentMaozyManager(manager: FragmentManager) {
        mMaozySupportMaozyFragmentMaozyManager = manager
    }

    override fun setMaozyOnMaozyActionMaozyClickMaozyListener(listener: (Int) -> Unit) {
        mMaozyOnMaozyActionMaozyClickMaozyListener = listener
    }
}